package ute.mvc.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import ute.mvc.dao.QuestionPoolDAO;
import ute.mvc.model.QuestionPool;
import ute.mvc.model.Subject;
import ute.mvc.model.User;

@Service("questionPoolService")
public class QuestionPoolServiceImpl implements QuestionPoolService {

	@Autowired
	QuestionPoolDAO questionPoolDAO;

	// Vinh
	public String getMaxIdInSubject(Subject subject) {
		return questionPoolDAO.getMaxIdInSubject(subject);
	}

	public List<QuestionPool> getAllQuestionPool() {
		return questionPoolDAO.getAllQuestionPool();
	}

	public List<QuestionPool> findQuestionPoolByName(String questionPoolName) {
		return questionPoolDAO.findQuestionPoolByName(questionPoolName);
	}

	@Transactional
	public void addQuestionPool(QuestionPool questionPool) {
		questionPoolDAO.addQuestionPool(questionPool);
	}

	@Transactional
	public void updateQuestionPool(QuestionPool questionPool) {
		questionPoolDAO.updateQuestionPool(questionPool);
	}

	@Transactional
	public void deleteQuestionPool(QuestionPool questionPool) {
		questionPoolDAO.deleteQuestionPool(questionPool);
	}

	public QuestionPool getQuestionPool(String poolId) {
		// TODO Auto-generated method stub
		return questionPoolDAO.getQuestionPool(poolId);
	}

	public List<QuestionPool> getPoolBySubjectLecturer(Subject subject,
			User lecturer) {
		// TODO Auto-generated method stub
		return questionPoolDAO.getPoolBySubjectLecturer(subject, lecturer);
	}

	public boolean isValidName(String name) {
		// TODO Auto-generated method stub

		if(questionPoolDAO.getPoolByName(name) == null){
			return true;
		}
		return false;
	}

	public QuestionPool getPoolByName(String name) {
		// TODO Auto-generated method stub
		return questionPoolDAO.getPoolByName(name);
	}

}
